/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Formas;

import java.awt.Graphics;

/**
 *
 * @author Pedro
 */
public class Circulo extends Retangulo {

    
    public Circulo(int sX, int sY, int width, int height)
    {
       super(sX,sY, width,height);
      
       xCentro = sX + (width / 2);
       yCentro = sY + (height / 2);
    }

    @Override
    public Forma drawForma(Graphics g) {
        g.setColor(super.getCor());
        g.drawOval(super.getsX(), super.getsY(), super.getWidth(), super.getHeight());
        return this;
    }

    @Override
    public boolean pertenceAForma(int x,int y) {
        int raio = super.getWidth() / 2;
        int sX = super.getWidth() / 2,sY = super.getHeight() / 2;
        return (Math.pow(x - xCentro, 2) + Math.pow(y - yCentro, 2)) < Math.pow(super.getWidth() / 2,2);
    }

   @Override
    public void setsX(int sX) {
        super.setsX(sX);
        xCentro = sX + (super.getWidth() / 2);
    }

    @Override
    public void setsY(int sY) {
        super.setsY(sY);
        yCentro = sY + (super.getHeight() / 2);
    }
}
